﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using DynamicTable;
using System.Reflection;

namespace www.serviciipeweb.ro.Obj2Print
{
    public static class PrintObjects
    {
        public static MemoryStream RDLTable_ForProperties(this object o)
        {
            if (o == null)
                return null;

            Type t = o.GetType();
            List<string> props = new List<string>();
            foreach (PropertyInfo p in t.GetProperties())
            {
                if (p.GetGetMethod() != null)
                    props.Add(p.Name);
            }
            MemoryStream ms = new MemoryStream();
            RdlGenerator gen = new RdlGenerator();
            gen.AllFields = props;
            gen.SelectedFields = props;
            gen.WriteXml(ms);
            ms.Position = 0;
            return ms;


        }

    }
}
